<?php

namespace api\libs\notifications\models;

use api\components\helpers\Constant;
use api\modules\app\models\DictContext;
use mdm\admin\models\User;
use api\components\Notification;
use Yii;

/**
 * This is the model class for table "notification_template".
 *
 * @property integer $id
 * @property string $name
 * @property integer $type
 * @property string $content
 * @property string $translate_rule
 * @property string $description
 * @property string $role
 * @property integer $status
 * @property string $start_time
 * @property string $end_time
 * @property integer $interval_time
 * @property string $mtime
 */
class NotificationTemplate extends \yii\db\ActiveRecord {

    /**
     * inbox notification
     */
    const TYPE_INBOX = 1;

    /**
     * email notification
     */
    const TYPE_EMAIL = 2;

    /**
     * sms notification
     */
    const TYPE_SMS = 3;
    
     /**
     * system  notification
     */
    const TYPE_SYSTEM_NOTICE = 4;
    
     /**
     * upgrade notification
     */
    const TYPE_UPGRADE_NOTICE = 5;

    /**
     * @inheritdoc
     */
    public static function tableName() {
        return 'notification_template';
    }

    /**
     * @inheritdoc
     */
    public function rules() {
        return [
                [['name', 'type', 'business_type', 'content', 'role'], 'required'],
                [['type', 'business_type', 'status', 'interval_time'], 'integer'],
                [['content'], 'string'],
                [['ctime', 'mtime', 'start_time', 'end_time'], 'safe'],
                [['name'], 'string', 'max' => 128],
                [['translate_rule'], 'string', 'max' => 512],
                [['description'], 'string', 'max' => 255],
                [['role'], 'string', 'max' => 64],
                ['status', 'in', 'range' => DictContext::getListByType(Constant::DICT_CONTEXT_TYPE_COMMON_STATUS)],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'type' => '模板类型 1-INBOX 2-EMAIL 3-SMS 4-SYSTEM NOTICE 5-UPDATE NOTICE',
            'business_type' => '业务类型 1-系统 2-审核 3-财务 4-账号',
            'content' => 'Content',
            'translate_rule' => 'Translate Rule',
            'description' => 'Description',
            'role' => 'Role',
            'status' => '0:enable, 1:disable',
            'start_time' => 'Start Time',
            'end_time' => 'End Time',
            'ctime' => 'Ctime',
            'cuser' => 'Cuser',
            'mtime' => 'Mtime',
            'muser' => 'Muser',
        ];
    }
}
